#pragma once
#ifndef AUDIOSTREAM_H
#define AUDIOSTREAM_H

#include <SFML\Audio.hpp>

#include <cstdint>

#include "SoundTransducer.h"

#define BUFFER_SIZE_TOTAL (512)

class AudioStream : public sf::SoundStream
{
public:
	AudioStream();
	~AudioStream();

	//von der parrent sfml klasse
	virtual bool onGetData(Chunk& data);
	virtual void onSeek(sf::Time timeOffset){};

	//aqnderes

	void Play();
	void Stop();

	void AddSignal(const double NewSignal);

	//sound TODO ENTFRENEN SIND UNREFERENZIERT
	sf::SoundBuffer Buffer;
	sf::Sound Sound;

	size_t WritePos;
	size_t ReadPos;
	int16_t SampleData[BUFFER_SIZE_TOTAL];
	//float FrequencyMod;
	
	bool Playing;

private:
	SoundTransducer			Transducer;

	const size_t GetBufferSize(){ return WritePos - ReadPos; }
	void Synchronize();
};

#endif